# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Simon Rupf <simon@rupf.net>
pkgname=xterm
pkgver=395
pkgrel=0
pkgdesc="X Terminal Emulator"
options="!check" # Requires vttest
url="https://invisible-island.net/xterm"
arch="all"
license="MIT"
depends="ncurses-terminfo-base"
makedepends="libxaw-dev libxft-dev ncurses-dev"
subpackages="$pkgname-doc"
source="https://invisible-island.net/archives/xterm/xterm-$pkgver.tgz"

# secfixes:
#   371-r0:
#     - CVE-2022-24130
#   366-r0:
#     - CVE-2021-27135

build() {
	export CFLAGS="$CFLAGS -flto=auto -D_BSD_SOURCE"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--with-x \
		--disable-full-tgetent \
		--disable-imake \
		--enable-ansi-color \
		--enable-88-color \
		--enable-256-color \
		--enable-broken-osc \
		--enable-broken-st \
		--enable-load-vt-fonts \
		--enable-i18n \
		--enable-wide-chars \
		--enable-doublechars \
		--enable-warnings \
		--enable-tcap-query \
		--enable-logging \
		--enable-dabbrev \
		--enable-freetype \
		--enable-luit \
		--enable-mini-luit \
		--enable-narrowproto \
		--enable-exec-xterm \
		--enable-sixel-graphics \
		--with-tty-group=tty \
		--with-utempter
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -m755 -d "$pkgdir"/usr/share/applications
	install -m644 "$builddir"/xterm.desktop "$pkgdir"/usr/share/applications/
	install -m644 "$builddir"/uxterm.desktop "$pkgdir"/usr/share/applications/
}

sha512sums="
a617f684f1e71eb7b7d33c505f408b90feaac604aa4ea70cb24d9b4eb78242f0eb4545aea81abcb2c51379ad54aa113ec88d445a9d290d5ff141ab0f1a009952  xterm-395.tgz
"
